//author:kakake
var Model = /** @class */ (function () {
    function Model() {
    }
    return Model;
}());

//author:kakake
var Common = /** @class */ (function () {
    function Common() {
    }
    return Common;
}());

//author:kakake
var tsTemplateService = /** @class */ (function () {
    function tsTemplateService() {
    }
    return tsTemplateService;
}());

//author:kakake
var tsTemplateDao = /** @class */ (function () {
    function tsTemplateDao() {
        this.dbConn = TSLobsterAPI.Program.GetDbConn();
    }
    return tsTemplateDao;
}());

//author:kakake
var tsTemplateController = /** @class */ (function () {
    function tsTemplateController() {
        this.data = {
            dbConn: TSLobsterAPI.Program.GetDbConn()
        };
    }
    //获取表单类型
    tsTemplateController.prototype.getlabeltype = function () {
        var strsql = "SELECT Type,Code,Name FROM PSQ_LabelType where DelFlag=0";
        var data = TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql);
        return { data: data };
    };
    //获取模板表单
    tsTemplateController.prototype.gettemplateform = function () {
        var keywords = TSLobsterAPI.Program.RequestQuery("keywords", '');
        var labeltype1 = TSLobsterAPI.Program.RequestQuery("labeltype1", '');
        var labeltype2 = TSLobsterAPI.Program.RequestQuery("labeltype2", '');
        var labeltype3 = TSLobsterAPI.Program.RequestQuery("labeltype3", '');
        var pageInfo = {
            key: "Id",
            page: TSLobsterAPI.Program.RequestQuery('page', 0),
            perPage: TSLobsterAPI.Program.RequestQuery('limit', 10),
            totalRecord: 0,
            totalPage: 0
        };
        var dbparams = {
            keywords: '%' + keywords + '%',
            labeltype1: labeltype1,
            labeltype2: labeltype2,
            labeltype3: labeltype3
        };
        var strsql = "SELECT Id,Title,Description,HeadPic FROM PSQ_TemplateForm WHERE Title LIKE @keywords ";
        if (labeltype1 != "") {
            strsql += " and LabelType1=@labeltype1";
        }
        if (labeltype2 != "") {
            strsql += " and LabelType2=@labeltype2";
        }
        if (labeltype3 != "") {
            strsql += " and LabelType3=@labeltype3";
        }
        var data = TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, dbparams, pageInfo);
        //更多
        var more = false;
        if (parseInt(pageInfo.page) < pageInfo.totalPage) {
            more = true;
        }
        return { data: data, more: more };
    };
    //获取模板
    tsTemplateController.prototype.getformobject = function () {
        var formid = TSLobsterAPI.Program.RequestQuery("formid", 0);
        var strsql = "SELECT Id,Title,Viewschema FROM PSQ_TemplateForm WHERE Id=@formid";
        var dbparams = {
            formid: formid
        };
        var obj = TSLobsterAPI.DbHelper.DbGetJsonObject(this.data.dbConn, strsql, dbparams);
        return { formobj: obj };
    };
    //保存模板头像
    tsTemplateController.prototype.saveheadpic = function () {
        var formid = TSLobsterAPI.Program.RequestQuery("formid", 0);
        var headpic = TSLobsterAPI.Program.RequestQuery("headpic", "");
        var dbparams = {
            formid: formid,
            headpic: headpic
        };
        var strsql = "update PSQ_TemplateForm set HeadPic=@headpic where Id=@formid";
        TSLobsterAPI.DbHelper.DbExecuteUpdate(this.data.dbConn, strsql, dbparams);
        return { result: true };
    };
    tsTemplateController.prototype.searchtemplateform = function () {
        var pageInfo = {
            key: "Id",
            page: TSLobsterAPI.Program.RequestQuery('page', 0),
            perPage: TSLobsterAPI.Program.RequestQuery('limit', 10),
            totalRecord: 0,
            totalPage: 0
        };
        var searchchar = TSLobsterAPI.Program.RequestQuery('searchchar', '');
        var dbparams = {
            searchchar: '%' + searchchar + '%'
        };
        var strsql = "SELECT Id,Title,Description,CreateUser,CreateTime,HeadPic FROM PSQ_TemplateForm WHERE Title LIKE @searchchar ";
        var data = TSLobsterAPI.DbHelper.DbGetJsonData(this.data.dbConn, strsql, dbparams, pageInfo);
        return { data: data, count: pageInfo.totalRecord };
    };
    return tsTemplateController;
}());

